package com.jkdz.spyke.flexUI.helpers {
	
	import flash.events.MouseEvent;
	
	import spark.components.Label;
	
	public class Link extends Label {
		
		private static const NORMAL_COLOR:int = 0xff888888;
		private static const HOVER_COLOR:int = 0xff333333;
		private static const CLICK_COLOR:int = 0xff999999;

		private static const NORMAL_COLOR_WHITY:int = 0xffeeeeee;
		private static const HOVER_COLOR_WHITY:int = 0xffcccccc;
		private static const CLICK_COLOR_WHITY:int = 0xfffffffe;

		public function Link(text:String, white:Boolean = false) {
			this.text = text;
			this.setStyle("whity", white);
			
			setStyle("color", getStyle("whity") ? NORMAL_COLOR_WHITY : NORMAL_COLOR);
			setStyle("textDecoration", "underline");
			useHandCursor = true;
			buttonMode = true;
			
			addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
			addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
			addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
			addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
		}
		
		protected function onMouseOver(event:MouseEvent):void {
			this.setStyle("color", getStyle("whity") ? HOVER_COLOR_WHITY : HOVER_COLOR);
		}
		
		protected function onMouseOut(event:MouseEvent):void {
			this.setStyle("color", getStyle("whity") ? NORMAL_COLOR_WHITY : NORMAL_COLOR);
		}
		
		protected function onMouseDown(event:MouseEvent):void {
			this.setStyle("color", getStyle("whity") ? CLICK_COLOR_WHITY : CLICK_COLOR);
		}
		
		protected function onMouseUp(event:MouseEvent):void {
			this.setStyle("color", getStyle("whity") ? HOVER_COLOR_WHITY : HOVER_COLOR);
		}
	}
}
